jQuery(function () {
	jQuery("#pagingList").jqGrid({
        url: "pagingList.json",
        colNames: ["ID", <#list columns as c> "${c}", </#list> "操作"],
        colModel: [
            { name: "${lowerPk}",key:true, width: 50 ,searchoptions:{//searchoptions 搜索条件配置
            	// sopt  代表条件配置方式  eq:==  ne:不等于  lt:小于 。。。
            	sopt : ['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc','nu','nn','bt']
            }},
            <#list columns as c>
            { name: "${c}", width: 50 ,searchoptions:{
            	sopt : ['eq','ne','bw','bn','ew','en','cn','nc','nu','nn','bt']
            }},
            </#list>
            { searchoptions:{
            	searchhidden:false
            },formatter: function (cellvalue, options, rowdata) {
                var html = "";
                html += "  <button onclick=\"window.location.href='edit.do?${lowerPk}="+rowdata.${lowerPk}+"&page_title=修改';\" type=\"button\" class=\"am-btn am-btn-primary am-btn-xs\">修改信息</button>";
                return html;
            }}
        ],
        pager: "#pagingList_pager",
    });
	jQuery('#pagingList').jqGrid('filterToolbar',{
		stringResult: true,
		searchOnEnter: true,
		searchOperators : true
	});
	jQuery('#pagingList').navGrid('#pagingList_pager',{ 
    	edit: false, 
    	add: false, 
    	del: false,
    	search: false,
    	refresh: true, 
    	view: false, 
    	position: "left", 
    	cloneToTop: true 
    });

	jQuery('#pagingList').navButtonAdd('#pagingList_pager',
    {
        buttonicon: "ui-icon-plus",
        title: "添加",
        caption: "添加",
        position: "last",
        onClickButton: function(){
			window.location.href='edit.do?name=添加';
        }
    });
	jQuery('#pagingList').navButtonAdd('#pagingList_pager',
    {
        buttonicon: "ui-icon-trash",
        title: "删除",
        caption: "删除",
        position: "last",
        onClickButton: function(){
        	var gr = jQuery("#pagingList").jqGrid('getGridParam','selarrrow');
        	if( gr == null || gr.length == 0 ){
        		demo_alert("删除提示","请选择条目。",function(){});
        		return;
        	}
        	demo_confirm("确认删除","是否删除？",function(){
        		${domainObjectName}.del(gr.join(","));
        	});
        }
    });
});